<template>
  <div class="app-container">
    <header>
      <p class="title">Read Our Latest Guides</p>
    </header>
    <main>
      <div class="left">
        <div
          v-for="(item, index) in menu_list.slice(0, 3)"
          :key="index"
          class="game"
        >
          <div class="image">
            <img v-lazy="item.image" alt="" @click="toPropsList(item)" />
          </div>
          <p class="name" @click="toPropsList(item)">{{ item.name }}</p>
        </div>
      </div>
      <div class="right">
        <div class="right-item">
          <div
            v-for="(item, index) in menu_list.slice(3, 6)"
            :key="index"
            class="game"
          >
            <div class="image">
              <img v-lazy="item.image" alt="" @click="toPropsList(item)" />
            </div>
            <p class="name" @click="toPropsList(item)">{{ item.name }}</p>
          </div>
        </div>
      </div>
    </main>
    <div class="line"></div>
  </div>
</template>

<script setup>
import { categories, productList } from "@/api/product";
import { useRoute, useRouter } from "vue-router";
import { ref } from "vue";

const route = useRoute();
const router = useRouter();

// 获取分类列表
const menu_list = ref([]);
const getProductList = () => {
  categories({
    parent_ids: [100306, 100307, 100308, 100301, 100302, 100303],
  }).then((res) => {
    menu_list.value = res.data;
  });
};
getProductList();

// 跳转道具列表
const toPropsList = (item) => {
  router.push({
    path: "/propsList",
    query: { id: item.id },
  });
};
</script>

<style lang="scss" scoped>
.app-container {
  margin-top: 20px;
  .title {
    padding: 40px 0 20px 0;
    background: linear-gradient(
      to top,
      rgba(255, 255, 255, 0),
      rgba(0, 107, 255, 0.1) 100%
    );
    font-size: 58px;
    line-height: 57px;
    font-weight: bold;
    color: #fff;
  }
  main {
    padding-top: 50px;
    display: flex;
    .left {
      width: 900px;
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      background: #263044;
      border-radius: 10px;
      padding-right: 10px;
      .game {
        .name {
          font-size: 18px;
          color: #fff;
          margin: 10px 0;
          text-align: center;
          cursor: pointer;
        }
        .name:hover {
          color: #ffa300;
          font-weight: bold;
        }
        .image {
          margin-top: 10px;
        }
        &:nth-child(1) {
          .image {
            margin-top: 0px;
          }
          img {
            width: 580px;
            height: auto;
          }
          grid-row: 1/3;
          grid-column: 1/3;
          .name {
            margin-top: 30px;
          }
        }
      }
    }
    .right {
      flex: 1;
      padding-left: 30px;
      // padding-top: 8px;
      .right-item {
        background: #263044;
        padding: 10px 20px;
        border-radius: 10px;
        .game {
          .name {
            font-size: 18px;
            color: #fff;
            margin: 10px 0;
            text-align: center;
            cursor: pointer;
          }
          .name:hover {
            color: #ffa300;
            font-weight: bold;
          }
          .image {
            margin-top: 10px;
          }
          &:nth-child(1) {
            .image {
              margin-top: 0px;
            }
            img {
              width: 580px;
              height: auto;
            }
            grid-row: 1/3;
            grid-column: 1/3;
            .name {
              margin-top: 30px;
            }
          }
        }
      }
    }
  }
  .line {
    width: 2px;
    height: 50px;
    background: #ffa300;
    margin: 40px auto;
    margin-bottom: 40px;
  }
}
</style>
